<template>
  <div>
     <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item>销售管理</el-breadcrumb-item>
      <el-breadcrumb-item>新增销售</el-breadcrumb-item>
    </el-breadcrumb>
    <el-divider></el-divider>
      <el-form 
      style="width: 500px" 
      ref="form"
      :rules="rules"
      :model="form" label-width="100px">
      <el-form-item label="品牌名称" prop="brandName">
        <el-input v-model="form.brandName"/>
      </el-form-item>
      <el-form-item label="品牌数量" prop="brandquantity">
        <el-input v-model="form.quantity"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submit">立即新增</el-button>
        <el-button>重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        form: {
          brandName: '', 
          brandquantity: ''
        },
        rules: {
          brandName: [
            {required:true, message:'该字段必填', trigger: 'blur'}
          ], 
          brandquantity: [
            {required:true, message:'该字段必填', trigger: 'blur'}
          ]
        }
      }
    },
    methods: {

      /** 提交表单 */
      submit(){
        this.$refs.form.validate(valid=>{
          if(valid){
            console.log('验证通过')
            // 发送请求, 执行新增业务
            let url = ""
            myaxios.post(url, this.form).then(res=>{
              console.log('新增品牌结果', res)
              if(res.data.code==200){
                this.$message({
                  message: '品牌新增成功',
                  type: 'success'
                })
                // 重置表单
                this.$refs.form.resetFields()
              }else{
                this.$message.error('新增失败, 请稍后重试')
              }
            })
          }else{
            console.log('验证失败')
          }
        })
      },
      
      /** 上传成功后执行 */
      handlequantitySuccess(res, ) {
        console.log(res)
        this.form.brandquantity = res.data
      },


      
    },
  }
</script>

<style lang="scss" scoped>

</style>